Hierarchical locking in B-tree indexes

ABSTRACT

Portions of a B-tree index in a database are locked for concurrency control. In one example, hierarchical lock modes are provided that permit locking a key, a gap between the key and the next key, and a combination of the key and the gap. In another example, key range locking may be applied to the B-tree index using locks on separator keys of index nodes. In another example, key range locking may be applied to the B-tree index using locks on key prefixes.

CROSS-REFERENCE TO RELATED APPLICATIONS

This application claims the benefit of:

U.S. patent application Ser. No. 11/539,606 filed Oct. 6, 2006, titled“HIERARCHICAL LOCKING IN B-TREE INDEXES”, now U.S. Pat. No. 7,577,658,which is incorporated by reference herein in its entirety;

co-pending U.S. patent application Ser. No. 12/499,624 filed Jul. 8,2009, titled “HIERARCHICAL LOCKING IN B-TREE INDEXES”, which is acontinuation of U.S. patent application Ser. No. 11/539,606, and whichis incorporated by reference herein in its entirety.

BACKGROUND

Database systems use locks to maintain the consistency of databases whenmultiple users are accessing the same data at the same time. Before atransaction acquires dependency on the current state of a piece of data,such as by reading or modifying the data, the transaction must protectitself from the effects of another transaction modifying the same data.The transaction may request a lock on the data. The transaction holdsthe lock protecting the modification until the end of the transaction.Locks held by a transaction are released when the transaction completes(either commits or rollbacks).

Hierarchical locking is widely used in database indexes. Hierarchicallocking lets large transactions take large (and thus few) locks and letsmany small transactions proceed concurrently by taking small locks. Thestandard lock hierarchy for B-tree indexes starts by locking the tableor view, then may lock the index or an index partition, and finally maylock a leaf page or individual key.

With the advent of disk drives approaching 1 Terabyte as well as verylarge databases and indexes, traditional hierarchical locking schemesbegin to show flaws. For example, the current step from locking an indexto locking its individual leaf pages or keys might prove too large.There may be millions of leaf pages and billions of keys in an index.Thus, if a lock on an entire index is too large and too restrictive forother transactions, thousands and maybe millions of individual locks arerequired. Conversely, if a transaction already holds 10,000 locks andthen escalates to an index lock to save on computing resources, thisindex lock might inhibit hundreds of concurrent transactions. Currenthierarchical locking schemes create a dilemma between locking an entireindex and locking millions of individual leaf pages or keys.

SUMMARY

The following presents a simplified summary of the disclosure in orderto provide a basic understanding to the reader. This summary is not anextensive overview of the disclosure and it does not identifykey/critical elements of the invention or delineate the scope of theinvention. Its sole purpose is to present some concepts disclosed hereinin a simplified form as a prelude to the more detailed description thatis presented later.

Embodiments herein provide hierarchical locking techniques for B-treeindexes. In one embodiment, hierarchical lock modes are provided thatpermit locking a key, a gap between the key and the next key, and acombination of the key and the gap. In another embodiment, key rangelocking is performed via separator keys. In yet another embodiment,locks on key prefixes are used to provide key range locking.

Many of the attendant features will be more readily appreciated as thesame become better understood by reference to the following detaileddescription considered in connection with the accompanying drawings.

BRIEF DESCRIPTION OF THE DRAWINGS

Like reference numerals are used to designate like parts in theaccompanying drawings.

FIG. 1 is a block diagram of an example operating environment forimplementing embodiments of the invention.

FIG. 2 is a block diagram of an example computing device forimplementing embodiments of the invention.

FIG. 3 is a block diagram of an example B-tree index structure inaccordance with an embodiment of the invention.

FIG. 4 shows a traditional lock compatibility matrix.

FIG. 5 shows a lock compatibility matrix in accordance with anembodiment of the invention.

FIG. 5B is a block diagram showing the logic and operations of insertinga new key using new lock modes in accordance with an embodiment of theinvention.

FIG. 6 is a block diagram showing the logic and operations of lockingseparator keys in accordance with an embodiment of the invention.

FIG. 7 is a block diagram showing the logic and operations of lockingseparator keys in accordance with an embodiment of the invention.

FIG. 8 is a block diagram showing the logic and operations of lockingseparator keys in accordance with an embodiment of the invention.

FIG. 9 is a block diagram showing the logic and operations of lockingseparator keys in accordance with an embodiment of the invention.

FIG. 10 is a block diagram showing the logic and operations of lockingseparator keys in accordance with an embodiment of the invention.

FIG. 11 is a block diagram showing the logic and operations of lockingseparator keys in accordance with an embodiment of the invention.

FIG. 12 is a block diagram showing the logic and operations of lockingkey prefixes in accordance with an embodiment of the invention.

FIG. 13 is a block diagram showing the logic and operations of lockingkey prefixes in accordance with an embodiment of the invention.

FIG. 14 is a block diagram showing the logic and operations of lockingkey prefixes in accordance with an embodiment of the invention.

DETAILED DESCRIPTION

The detailed description provided below in connection with the appendeddrawings is intended as a description of the present examples and is notintended to represent the only forms in which the present examples maybe constructed or utilized. The description sets forth the functions ofthe examples and the sequence of steps for constructing and operatingthe examples. However, the same or equivalent functions and sequencesmay be accomplished by different examples.

FIG. 1 shows an embodiment of an operating environment 100 forimplementing embodiments of the invention. FIG. 1 and the followingdiscussion are intended to provide a brief, general description of asuitable computing environment to implement embodiments of theinvention. The operating environment 100 is only one example of asuitable operating environment and is not intended to suggest anylimitation as to the scope of use or functionality of the operatingenvironment.

Operating environment 100 includes a network 102. Network 102 mayinclude an internet, an intranet, and the like. A server 108 maycommunicate with computing devices 104, 105, and 106 over network 102.An example computing device is described below in connection with FIG.2. Computing devices 104-106 include client devices and/or servers thatmay access data in the database hosted by server 108.

Server 108 may include a server operating system (OS) 110. An embodimentof server OS 110 includes Microsoft Windows Server®. Server OS 110 maysupport a database (DB) system 112. An embodiment of database system 112includes Microsoft SQL Server. A single server 108 is shown for the sakeof clarity, but it will be understood operating environment 100 mayinclude multiple servers 108.

Database system 112 may include a database engine 114. Database engine114 is a service for storing, processing, and securing data. Databaseengine 114 provides access and transaction processing for dataconsumers. Database system 112 may include others services (not shown)such as analysis services, data mining tools, replication services,reporting services, notification services, and the like.

Server 108 may access a database storage 120 that stores data managed bydatabase system 112. DB storage 120 may be external to server 108 (asshown in FIG. 1), internal to server 108, or a combination thereof.While a single DB storage 120 is shown for the sake of clarity, but itwill be understood that multiple DB storage units 120 may be used.Further, DB storage 120 associated with database system 112 may be localto server 108, distributed across a network, or any combination thereof.

Database system 114 may include a lock manager 116. In one embodiment,when database engine 114 receives a transaction request, database engine114 determines which resources are to be accessed. Database engine 114determines what types of locks are required. Database engine 114 thenrequests the appropriate locks from lock manager 116. Lock manager 116grants the locks if there are no conflicting locks held by othertransactions. As described herein, data base engine 114 may use varioushierarchical locking techniques. Database engine 114 may also performother locking procedures, such as lock escalation/de-escalation and lockgranularity changes, as described herein.

FIG. 2 shows an embodiment of a computing device 200 for implementingone or more embodiments of the invention. In one embodiment, computingdevice 200 may be used as server 108. In its most basic configuration,computing device 200 typically includes at least one processing unit 202and memory 204. Depending on the exact configuration and type ofcomputing device, memory 204 may be volatile (such as RAM), non-volatile(such as ROM, flash memory, etc.) or some combination of the two. Thismost basic configuration is illustrated in FIG. 2 by dashed line 206.

Additionally, device 200 may also have additional features and/orfunctionality. For example, device 200 may also include additionalstorage (e.g., removable and/or non-removable) including, but notlimited to, magnetic or optical disks or tape. Such additional storageis illustrated in FIG. 2 by storage 208. In one embodiment, computerreadable instructions to implement embodiments of the invention may bestored in storage 208, shown as DB engine 114. Storage 208 may alsostore other computer readable instructions to implement an operatingsystem, an application program, and the like.

Although not required, embodiments of the invention will be described inthe general context of “computer readable instructions” being executedby one or more computing devices. Computer readable instructions may bedistributed via computer readable media (discussed below). Computerreadable instructions may be implemented as program modules, such asfunctions, objects, application programming interfaces (APIs), datastructures, and the like, that perform particular tasks or implementparticular abstract data types. Typically, the functionality of thecomputer readable instructions may be combined or distributed as desiredin various environments.

The term “computer readable media” as used herein includes computerstorage media. Computer storage media includes volatile and nonvolatile,removable and non-removable media implemented in any method ortechnology for storage of information such as computer readableinstructions, data structures, program modules, or other data. Memory204 and storage 208 are examples of computer storage media. Computerstorage media includes, but is not limited to, RAM, ROM, EEPROM, flashmemory or other memory technology, CD-ROM, digital versatile disks(DVDs) or other optical storage, magnetic cassettes, magnetic tape,magnetic disk storage or other magnetic storage devices, or any othermedium which can be used to store the desired information and which canbe accessed by device 200. Any such computer storage media may be partof device 200.

The term “computer readable media” may include communication media.Device 200 may also include communication connection(s) 212 that allowthe device 200 to communicate with other devices, such as with othercomputing devices through network 220. Communication media typicallyembodies computer readable instructions, data structures, programmodules or other data in a modulated data signal such as a carrier waveor other transport mechanism and includes any information deliverymedia. The term “modulated data signal” means a signal that has one ormore of its characteristics set or changed in such a manner as to encodeinformation in the signal. By way of example, and not limitation,communication media includes wired media such as a wired network ordirect-wired connection, and wireless media such as acoustic, radiofrequency, infrared, and other wireless media.

Device 200 may also have input device(s) 214 such as keyboard, mouse,pen, voice input device, touch input device, laser range finder,infra-red cameras, video input devices, and/or any other input device.Output device(s) 216 such as one or more displays, speakers, printers,and/or any other output device may also be included.

Those skilled in the art will realize that storage devices utilized tostore computer readable instructions may be distributed across anetwork. For example, a computing device 230 accessible via network 220may store computer readable instructions to implement one or moreembodiments of the invention. Computing device 200 may access computingdevice 230 and download a part or all of the computer readableinstructions for execution. Alternatively, computing device 200 maydownload pieces of the computer readable instructions, as needed, orsome instructions may be executed at computing device 200 and some atcomputing device 230. Those skilled in the art will also realize thatall or a portion of the computer readable instructions may be carriedout by a dedicated circuit, such as a Digital Signal Processor (DSP),programmable logic array, and the like.

1 INTRODUCTION TO B-TREES

Embodiments of the invention provide locking mechanisms for B-treeindexes. An example B-tree index 302 is shown in FIG. 3. Table 300 is adatabase object that organizes data in columns and rows. Each rowrepresents a unique record, and each column represents a field withinthe record. For example, a table of contact addresses may include a rowfor each person and columns for first name, last name, street address,city, state, and zip code.

B-tree index 302 is an index structure associated with table 300. B-treeindex 302 has keys associated with one or more columns in table 300. Thekeys are stored in the B-tree index 302 in such a way to enable the database system to quickly find the row or rows using particular key values.

B-tree 302 includes three-levels: a root node level 308, a branch nodelevel 306, and leaf node level 304. A root node 311 includes pointers tobranch nodes. A branch node includes pointers to leaf nodes or otherbranch nodes. FIG. 3 shows one branch node level for the sake ofclarity, but it will be understood B-tree indexes may include multiplebranch node levels and thus more than three levels total. In otherembodiments, a B-tree may include less than three levels (for example,in the case where a single page is sufficient for a root index andleaves).

Index nodes, such as root nodes and branch nodes, include key-pointerpairs. For example, index node 303 includes key-pointer pair 305.Usually, an index node includes a sorted sequence of keys (and theirassociated pointers) that divides the search space covered by the indexnode. An index node may contain no actual data, but hold indexinformation to guide a search for a given key value. The key-pointerpair 305 may be called a separator key because it separates key valuesat index node 303 into two nodes (leaf nodes in this example).

A leaf node, such as leaf node 307, includes index items and may alsoinclude pointers to neighboring leaf nodes. Leaf nodes may include oneor more index items, such as index item 310, which contain a key and rowinformation. The key represents the value of the indexed column for aparticular row in table 300. The row information may include the actualdata for the row in table 300 or a pointer to such data (i.e., aclustered index or an non-clustered index).

Embodiments of the invention may include aspects of B-tree indexing asfollows. Embodiments herein may employ user transaction and/or systemtransactions. A user transaction includes a database access requestinitiated by a user (for example, a human or a computing process).System transactions may modify the database representation but not itscontents and therefore permit certain optimizations such as commitwithout forcing the transaction log.

In one embodiment, a system transaction may be used to remove ghostrecords left behind after deletions by user transactions. Separation oflogical deletion (turning a record into a ghost) and physical deletion(reclaiming the record's space) serve various purposes such assimplified rollback for the user transaction if required, increasedconcurrency during the user transaction (locking a single key valuerather than a range), and reduced overall log volume. If the ghostremoval can capture record deletion and transaction commit in a singlelog record, there is never any need to log undo information (that is,the deleted record's non-key contents).

Embodiments herein include lock escalation and de-escalation. Lockescalation and de-escalation are useful due to unpredictable concurrencycontention and due to inaccuracy of cardinality estimation during queryoptimization. Lock escalation reduces overhead for queries withunexpectedly large results. It saves both invocations of the lockmanager and memory for managing the locks.

Lock de-escalation reduces contention. In one embodiment, lockde-escalation requires that each transaction retain, intransaction-private memory, the information required to obtain theappropriate fine-grain locks. For example, even if a transaction holds ashared lock on an entire index, it must retain information about theleaf pages read as long as de-escalation to page locking might becomedesirable or required.

Initial large locks combined with on-demand lock de-escalation canimprove performance, because detail locks can be acquired without fearof conflict and thus without search in the lock manager's hash table.

In some embodiments, for large index-order B-tree scans, the parent andgrandparent nodes enable deep read-ahead. Thus, accessing those nodesand their separator keys does not incur any extra I/O, and it isconceivable to lock those nodes or separator keys if desired.

In some embodiments, nodes may include fence keys. Each node split postsa separator key in the parent node, but also retains a copy of theseparator key (the fence key) in the two sibling nodes resulting fromthe split. Such fence keys aid B-tree operations in multiple operationsincluding key range locking and de-fragmentation.

In embodiments of the invention, all B-tree entries are unique. It isnot required that the declared search keys are unique; however, theentries must have identifying information such that a row deletion leadsto deletion of the correct B-tree entry. Standard mechanisms for thispurpose are to add the row pointer in the sort order of non-clusteredindexes and to add “uniquifier” numbers to clustered index keys.

2 NEW LOCK MODES FOR KEYS AND KEY RANGES

Embodiments of the invention include new lock modes for key rangelocking in B-tree indexes. In key range locking, a key-range lock isplaced on an index entry specifying a beginning or ending key value. Thekey-range lock may block attempts to insert, update, or delete any rowwith a key value that falls in the range because those operations wouldfirst have to acquire a lock on the index. Embodiments of new lock modesdiscussed below provide a simplification for traditional key rangelocking, avoid irregular complexities such as instant locks and insertlocks, and increase permitted concurrency when applied to keys in B-treeleaves.

FIG. 4 shows a traditional lock compatibility matrix 400. The columnsshow the existing granted lock mode on a resource and the rows show therequested lock mode. The lock modes include shared (S), exclusive (X),intent shared (IS), and intent exclusive (IX). A shared lock mode may beused for operations, such as read, that do not change data. An exclusivelock mode may be used for data-modification operations.

An intent lock mode may be used to establish a lock hierarchy. Ingeneral, intent locks (also referred to as intention locks) are acquiredbefore a lock at a lower level in the locking hierarchy to signal theintent to place locks at the lower level. Typical intent locks includeintent shared (IS), intent exclusive (IX), and shared with intentexclusive (SIX). Intent locks prevent other transactions from lockingthe higher-level resource in a way that would contradict the lock at thelower level.

Compatibility matrix 400 shows whether two locks may co-exist on thesame resource, such as a key. For example, two shared locks may co-exist(shown by a Yes (Y) at the row-column intersection of the S locks inmatrix 400). In another example, X and S locks may not co-exist (shownby a No (N) at the row-column intersections of the S and X in matrix400). X and S lock modes are not compatible because when an X lock isheld, no other transaction may acquire a lock of any kind on thatresource until the X lock is released. Using the lock modes in matrix400, the key value, the gap between keys, and the combination of keyvalue and gap are three separate resources that are locked usingdifferent locks and thus separate invocations of the lock manager.

Referring to FIG. 5, an embodiment of a lock compatibility matrix 500including new lock modes is shown. Embodiments of new lock modesdescribed herein take advantage of the fact that the key value serves asidentifier for all three resources (i.e., key, gap, and key-gapcombination) in the lock manager's hash table, which permits employingonly one resource and one invocation of the lock manager at the expenseof additional lock modes.

The new lock modes shown in matrix 500 permit locking a key and the gapbetween two keys separately. For the purpose of discussion herein, the“implied” intent locks (discussed below) apply to the combination of keyand gap between keys. The absolute locks can apply to the key, the gapbetween keys, or their combination.

The new lock modes may be thought of as having a key component and a gapcomponent, where the gap represents the gap between two key values notincluding the key values marking the ends of the gap. Matrix 500introduces the symbol “Ø” which represents a null on either the keycomponent or the gap component of the lock mode. The new lock modesinclude key shared (SØ), gap shared (ØS), key exclusive (XØ), gapexclusive (ØX), key shared gap exclusive (SX), key exclusive gap shared(XS).

For example, assume a key range based on last names of “Albertson” to“Connor.” An SØ lock on “Albertson” would put a shared lock on“Albertson” and no lock on the gap between “Albertson” and “Connor”excluding “Albertson” and “Connor.” An SX lock on “Albertson” would puta shared lock on “Albertson” and an exclusive lock on the gap between“Albertson” and “Connor” excluding “Albertson” and “Connor.”

These new lock modes are identified by a key value, but they representlocks on the key value itself, the gap between key values, and thecombination of the key value and gap. For example, the new lock mode SØlocks the combination of key and gap in IS mode, the key in S mode, andthe gap not at all. Conversely, ØS puts a shared lock on the openinterval (K_(i), K_(i+1)) and leaves the key value unlocked (where K isa key value).

The new lock mode XØ locks the key exclusively and the gap not all.Conversely, ØX does not lock the key, but locks the gap exclusively.Lock mode SX locks the key and gap combination in IX mode, the key in Smode, and the gap in X mode. Lock mode XS locks the key exclusively, thegap in shared mode, and the combination of key and gap in IS mode.

It will be noted that intention locks are not part of the names for thenew lock modes but intention locks are implied. The new lock modes areidentified by a key value, but they represent locks on the key valueitself, the gap between key values, and the combination of the key valueand the gap. IS and IX lock modes are not shown because they do notapply to key values in this scheme other than implied by the new lockmodes. The combination of the locking the key and the gap in a singlelock may act as an intention lock (for example, IS or IX). Also, oneshould avoid any confusion with combination lock modes, such as SIX,which represents two locks on the same resource.

The derivations of the compatibility values in matrix 500 followdirectly from the construction of the lock modes themselves. Forexample, SØ and ØX are compatible because both take intention locks forthe combination of key value and gap, and one transaction locks the keyvalue in S mode whereas the other transaction locks the gap in X mode.Similarly, XØ and ØX are compatible, as are SØ and SX.

2.1 Insertion of a New Key

Insertion of a new key (and associated record) may be implemented as asystem transaction. The system transaction invoked for key insertionleaves behind a ghost record that the user transaction can lock in keyvalue mode and then turn into a valid record to effect the logicalinsertion. This is analogous to key deletion implemented by turningvalid B-tree records into ghost records with asynchronous ghost removalusing system transactions.

The system transaction places a lock on the gap for inserting the newkey (e.g., by placing an ØX lock on a pre-existing key next to the gap).The value of the system transaction for key insertion is that itreleases its lock on the gap between pre-existing keys when it commits.The follow on user transaction inherits a lock only on the new keyvalue, not on the gap (that is, an XØ lock on the new key). By holdingthis XØ lock until it commits, the user transaction can modify therecord from a ghost to a valid record. In the case of a rollback, theghost record remains and may be removed like other ghost records (forexample, upon request by a future user transaction that requires morespace in the B-tree leaf).

For example, turning to FIG. 5B, a gap 506 is shown between pre-existingkeys 9 and 12 (it will be understood that gap 506 is a logical gap, andnot a physical gap between the pre-existing keys). Also, pre-existingkeys 9 and 12 have associated records that are not shown for clarity.

To insert a new key 10 between pre-existing keys 9 and 12, a systemtransaction 520 places an ØX lock on key 9 to lock the gap between keys9 and 12. System transaction 520 inserts new key 10 (and associatedghost record 524) in gap 506. User transaction 530 inherits an XØ lockon new key 10 and then converts the ghost record to a valid record 532to complete the insertion. It will be understood that a lock may beplaced on new key 10 and its associated ghost record.

In the meantime, another user transaction or a system transaction maylock the gap defined by the new key. Using an ØX lock on the new key(which really locks the gap defined by the new key), this othertransaction may insert yet another key into the gap defined by thepre-existing key. Thus, embodiments herein support high insertion rateswithin a page and an index without any need to introduce irregularcomplexities such as instant locks and range locks that do not fit thetraditional theories of two-phase locking and of hierarchical locking.

Moreover, the system transaction locks only the gap into which itinserts the new key; it has no need to lock the pre-existing key valuethat identifies the gap. Thus, another transaction can concurrently readthe record with the pre-existing key. In FIG. 5B, another transactioncan read the record associated with pre-existing key 9 concurrent withthe insertion of new key 10. It can update and even delete the recordwith pre-existing key 9 if deletion is implemented by turning the validrecord into a ghost record. Neither concurrent reading nor concurrentupdates is possible in locking schemes without locks on the openinterval between keys (for example, traditional key range locking). Thesystem transaction of inserting a new key into a gap is compatible withany of these actions on the pre-existing key as long as the key is noterased from the B-tree. Thus, interference among neighboring keys isminimized by use of ghost records and system transactions. One skilledin the art having the benefit of this description will understand thatthe new lock modes may also be used for deletion of a key and associatedrecord (e.g., turn a valid record into a ghost record and then reclaimthe ghost record space).

A system transaction may be very efficient; a single log record maycover transaction start, key insertion, and transaction commit. Inworkloads that append many B-tree keys with predictable keys (forexample, order number in an order-entry application), a systemtransaction may create multiple ghost records such that multiple usertransactions each can find an appropriate ghost record that merely needsupdating, without creating a new record or a new lockable resource.

3 LOCKS ON SEPARATOR KEYS

Embodiments of key range locking on separator keys exploits the treestructure of the B-tree for multi-level hierarchical locking. Separatorkey range locking may be used in interior index nodes (e.g., branchnodes and root nodes). A lock on a separator key represents the entirekey range from one separator key to its next neighbor but not includingthe neighbor. Both intention locks and absolute locks can be employed onseparator keys as well as combinations (e.g., SIX).

FIG. 6 shows a portion of an example B-tree 602. B-tree 602 includes agrandparent index node 608, a parent index node 606, and leaf level 604having leaf nodes 610-612, where the parent and grandparent levels arein reference to leaf level 604. A separator record 603 includes aseparator key 607 and associated pointer. Separator record 603 makes aseparation between two leaf nodes 610 and 611. As described below,locking separator key 607 would have the similar affect as putting arange lock on the entire leaf node 611. The lock on separator key 607locks the key range up to the next separator record 609.

Locking key ranges at the parent level results in locking overheard andconcurrency behavior similar to traditional locking on leaf pages. A keyrange lock at the grandparent level, however, covers a much larger keyrange. Depending on a node's fan-out, a range lock at the grandparentlevel may save tens or hundreds of locks at the parent level, just likea key range lock in a parent node covers tens or hundreds of individualkeys.

Traditional lock modes may be applied to separator keys and cover thehalf-open range from the locked separator key (inclusively) to the nextseparator key (exclusively). For the highest key value in a node, afence key may be used to delimit the range protected by the range lock.A fence key includes a copy of the separator key in the node's parent.For the lowest key range (i.e., the node's “left-most” child), the fencekey is required as it determines the key value to lock. Many systemsretain the lowest separator key even if the systems do not employ fencekeys in general.

Locks on separator keys in parents are identified by the indexidentifier, the key value, and the node level within the B-tree. Nodelevels are commonly stored in each node's page header, with level 0assigned to leaves. The node level one up from the leaf level (i.e., theparent node) is node level 1 and so on.

Note that this identification of locks does not refer to a physicallocation (for example, a page identifier) but a logical location in theB-tree. Thus, locks remain valid even if a separator key migrates into anew node when a node splits, when two nodes merge, or when twoneighboring nodes balance their load.

3.1 Splitting and Merging Nodes

A node split may occur when a new row is inserted into a leaf page thatalready has reached its maximum number of entries. In one embodiment,the leaf page is split into two leaf pages and the entries from theoriginal leaf page are distributed evenly between the two new leafpages. A separator key between the two new leaf pages is pushed up tothe index node that holds the pointer to the split leaf page.

An example of splitting is shown in FIG. 7. B-tree 702 results from thesplitting of leaf 611 in B-tree 602 of FIG. 6. Key value 14 was to beinserted into leaf 611, but since leaf 611 was full, leaf 611 was splitinto leaves 704 and 706. As a result, a new separator record 708 wasadded to parent index node 606.

Two leaf nodes may merge when the number of entries in a leaf page fallsbelow a threshold (for example, 50% of maximum). The index items arecopied from one leaf node to another and the separator record in theparent node is removed.

When a node splits, a new separator key is inserted in its parent. Thisnew separator key divides a prior gap between two neighboring separatorkeys and thus disturbs existing locks covering this range. In order toensure that existing transactions are not materially affected, theirlocks on the range are duplicated and applied to the new separator key.This procedure permits page splits at all levels without interruptingthe flow of transaction processing. Also, this procedure ensures that notransaction's locked predicate is modified due to a change in thephysical B-tree structure. Referring to the splitting in FIG. 7, thelocks on separator key 607 have been duplicated and are applied to thenew separator key “15” in separator record 708 to maintain the locksover the same key ranges.

When two nodes merge, the opposite procedure applies. As ranges mergewith the removal of a separator key, transactions end up holding lockson the entire range, as if they had locked both original ranges equally.In this case, the lock manager verifies that the combined set of locksdoes not include conflicts. For example, assume an S lock on oneoriginal range and an IX lock in the other original range. In thisexample, the node merge operation is delayed because the S and IX locksare not compatible (refer to FIG. 4). The merge operation will bedelayed until one of the locks is released and, thus, the conflict iseliminated.

Embodiments of locking on separator keys may include load balancingbetween neighboring nodes. In one design, load balancing among twoneighboring nodes may be accurate in its locking but fairly complex dueto the shift in key ranges between neighboring nodes. In this case, theload balancing logic determines the locks needed on the parents fromlocks held on the child node entries that migrate.

In another design, load balancing may be made simple. The simple methodmodels load balancing as a merge operation followed by a splitoperation. In other words, the neighboring nodes are merged and thensplit back into two nodes having substantially equal entries. However,the locking may not be as accurate.

3.2 Lock Escalation and De-Escalation

Lock escalation converts many fine-grain locks into fewer coarse grainlocks. De-escalation performs the inverse operations. Lock escalationreduces system overhead due to managing fewer locks while increasing theprobability of lock conflicts. Escalation upgrades a lock from anintention lock to an absolute lock. Many fine-grain locks resulting fromde-escalation reduce the odds of concurrency contention but increaselock management due to the increase in the number of locks.De-escalation downgrades a lock from an absolute lock to an intentionlock.

Embodiments of locks on separator keys may include lock escalation andde-escalation functionality. Locking within a B-tree may start with keylocking in the leaves' parents or it may start at the grandparent levelin order to cover larger key ranges and thus require fewer locks inlarge range scans.

If range locking starts with intention locks on separator keys at thegrandparent level (for example, IS locks) and continues with absolutelocks on separator keys at the parent level (for example, S locks), bothlock escalation (for example, lock escalation to absolute locks in thegrandparents) and de-escalation (for example, lock de-escalation tointention locks in the parents and absolute locks in the leaves) may berequired.

Referring to FIG. 8, a B-tree 800 is shown having a grandparent level820, a parent level 822, and a leaf level 824. In the example of FIG. 8,B-tree 800 is indexed based on last name. Assume that B-tree 800 hasintention locks (IS or IX) on key ranges in grandparent node 802,absolute locks (S or X) on key ranges in parent node 806, and no lockson keys in leaf nodes 810, 812, and 814. In an example shown in FIG. 8,node 802 has on IS lock on the half-open key range interval [D . . . N)in node 802. Node 806 has an S lock on the half-open key range interval[F . . . G) in node 806. Node 812 has no lock on the key “Franklin” innode 812.

Referring to FIG. 9, for lock escalation, the intention lock atgrandparent node 802 becomes an absolute lock (an S lock in the exampleof FIG. 9). The only remaining locks will be absolute locks (S or X) onkey ranges in grandparent node 802. The locks at parent level 822 nowbecome obsolete due to the absolute lock at grandparent level 820 andmay be eliminated. In one embodiment, the locks at parent level 822 maybe erased. In another embodiment, the locks at parent level 822 may beretained in the lock manager or in transaction-private memory for futurelock de-escalation, which may be desired due to increasing contention ordue to a partial transaction rollback.

In the example shown in FIG. 9, in node 802, the open-interval IS lockhas escalated to an S lock on key range [D . . . N). Thus, no locks arenecessary on key range [F . . . G) at node 806 and key “Franklin” innode 812.

Referring to FIG. 10, for lock de-escalation of the locks in FIG. 8, theabsolute locks at parent level 822 become intention locks. In FIG. 10,intention locks will be maintained in grandparent node 802. The absolutelocks on parent node 806 become intention locks and absolute locks willbe placed in the leaves 810, 812, and 814. In the example shown in FIG.10, the S lock on key range [F . . . G) is de-escalated to an IS lockand an S lock is placed on the key “Franklin” of node 812.

In one embodiment, this de-escalation includes proactive gathering ofrequired leaf-level key locks during initial processing before thede-escalation actually occurs. These pre-gathered leaf-level locks maybe stored in transaction-private memory. During de-escalation, afterthese leaf-level locks have been propagated from transaction-privatememory to the global lock manager's hash table, the absolute lock on theseparator key in the parent can be relaxed to an intention lock.

In one embodiment, partial transaction rollback will not reverse thisde-escalation because reversal requires upgrading a lock, which mightfail due to locks held by concurrent transactions. In fact, after lockde-escalation due to contention by concurrent transactions, it is likelythat such a lock upgrade (from an intention lock to an absolute lock inthe parent nodes) during partial transaction rollback will fail.

3.3 Granularity Changes

Existing designs for hierarchical locking employ a fixed set of levelsat which locks are required. For example, a hierarchy of physicalcontainers might be database, file, page, and record. A hierarchy oflogical containers within a database might be table, index, indexpartition, and key. Within each such hierarchy, a transaction mayrequest a lock at a lower granularity of locking (e.g., a page) onlyafter acquisition of an appropriate intention lock on the next-highergranularity of locking (e.g., the file containing the desired page).

Embodiments herein use granularity changes to adjust the set of levelsin a hierarchy. For example, embodiments herein permit removing agranularity of locking from a hierarchy, such as a change fromtable-index-index partition-key to table-index-key. Inversely,embodiments herein permit introducing a new granularity of locking intoa hierarchy, e.g., from table-index-key to table-index-indexpartition-key. Embodiments herein permit such changes while transactionsare active (i.e., dynamically), including transactions that hold ordesire locks on the granularity of locking being removed or beingintroduced.

Embodiments herein may include granularity changes of separator keylocks. A granularity change involves a change in the set of B-tree nodeswhere ranges are locked. In embodiments herein, a node may be marked forlocking to lock the node's key ranges or a mark on a node may be removedto remove the lock on the node's key ranges.

As a comparison, lock escalation and de-escalation involve changinglocks in a particular B-tree node between an intention mode and anabsolute mode. In examples of lock escalation/de-escalation above,acquisition of the first locks occurred in the leaves' grandparents.This starting point may be adjusted dynamically and online (that is,without disruption of transaction processing) using granularity changes.

In FIG. 11, grandparent node 802 is not marked for locking and no locksare taken on separator keys in node 802. Parent node 806 is marked suchthat key range locks are taken on separator keys in parent node 806.Leaf node 812 is also marked for locking. The other nodes in FIG. 11have been set as mark or no mark, but this is not shown for the sake ofclarity. In one embodiment, a node includes a Boolean mark/no markfield.

Setting a mark on a node signals that a lock request is required to thelock manager for at least one separator key in the node (along with thesearch path from the root node to the sought leaf node entry). It isemphasized that nodes are marked, but locks are placed on one or morekeys within a marked node.

Setting a mark on a node (for example, setting a mark on grandparentnode 802) may be either immediate or delayed. An advantage of theimmediate method is that a transaction may request lock escalation evento a node in which no transaction has acquired locks. However, thedelayed mode takes substantially less search in the lock manager's hashtable than the immediate method.

In one embodiment, the immediate method searches in the lock manager'shash table for active transactions that ought to hold intention locks.These transactions can be found by searching for locks on separator keysin the node's children (for example, nodes 804, 806, and 808 that arechildren to node 802). For all such transactions, appropriate intentionlocks for the appropriate separator keys in the present node areinserted into the lock manager. Thus, intention locks may be set onseparator keys in node 802 where the separator key points to a childnode that already has separator key locks.

While the search for such transactions is time expensive, acquisition ofthe new intention locks is very fast as there is no need to search forconflicting locks. The correctness of the immediate method relies on itscorrect acquisition of all intention locks that would have been heldalready if the mark had been set on the node before any of the activetransaction began.

In one embodiment, the delayed method forces all new transactions toacquire intention locks and prevents acquisition of absolute locks inthe node until all older transactions have completed. To do so, thedelayed method employs two system transactions. The first systemtransaction marks the node for locking, thus forcing all futuretransactions to acquire intention locks when descending the B-tree. InFIG. 11, node 802 is marked for locking. A second concurrent systemtransaction obtains IX locks on all separator keys in the node (forexample, node 802), observes the set of currently active transactions,waits until the last one of those has finished, and then commits the IXlocks. For the duration of these IX locks, no transactions may acquirean absolute lock on keys in the child nodes (recall from FIG. 4 that IXlocks are incompatible with S and X locks). The correctness of thedelayed method relies on a system transaction holding IX locks on allkeys on behalf of all active transactions, whether those transactionsactually require them or not.

When a non-leaf mode is split (for example, grandparent node 802 orparent node 806), both resulting nodes inherit the mark from theoriginal node. A split operation can proceed even while a granularitychange is on-going, whether the immediate or delayed method is employed.

For two nodes to merge, they must be marked equally first, that is, amodification in the granularity of locking might be needed prior to anode merge operation.

Removing a node's mark (for example, removing the mark on node 806 inFIG. 8), follows a procedure similar to the delayed method above. Onesystem transaction erases the mark so that future transactions do notacquire locks, while another system transaction obtains IX locks on allkeys in the node (waiting for other transactions to release theirabsolute locks, if any, on those keys) and then commits.

Embodiments of granularity changing may occur dynamically. In otherwords, the introduction and removal of levels in a lock hierarchy mayoccur on demand by the database engine and without disruptingtransaction processing. These dynamic changes may be exploited in manyways. For example, assume in order to maximize transaction processingperformance, only keys in leaf nodes are locked by default. However, ifthe database engine determines that a transaction would benefit from alarger granularity of locking (for example, locking the key range of anentire leaf page instead of numerous individual locks in the leaf page),then key range locking can be introduced specifically in those parentsand grandparents that benefit the transaction. When no longeradvantageous, the granularity of locking may be adjusted as appropriateto continually maximize transaction processing performance.

Both setting and removing a node's mark are local operations that hardlyaffect data availability. Note that new user transactions can lock keysin a node while a system transaction holds IX locks; these IX locks donot conflict with other intention locks, only with absolute locks.

The set of nodes marked for locks on separator keys has fewrestrictions. For example, it is possible that a node is marked but someof its siblings are not, or that a leaf's parent is not marked but itsgrandparent is (skip-level locking). These examples may seemcounter-intuitive, but they might be appropriate intermediate stateswhile an entire B-tree is converted to a different granularity oflocking, or they might be permanent states tuned for skew in the datadistribution or in the access pattern.

In one embodiment, policies may be used to govern granularity changes.For transaction processing systems, an initial policy might start withlocking keys in the leaves only and locking separator keys in the upperB-tree nodes only inasmuch as necessary for lock escalation. In otherwords, non-leaf nodes are marked as described above only on demand.Similarly, marks are removed after their benefit ceases, that is, nodesremain marked only during demand. For relational data warehousing, locksin parent and grandparent nodes seem like a reasonable default,depending on the amount of incremental online information flow frombusiness processes.

Embodiments herein may lock separator keys in non-leaf B-tree nodes.Locking separator keys scales with the size and the height of the B-treeindex. The stepping factor is fairly uniform across all levels of theindex, even in an index with a non-uniform key value distribution.Typical values for the stepping factor may be 100 to 1,000; the lattervalue requiring large pages or very short keys (for example, due toaggressive prefix or suffix truncation). Thus, the databaseadministrator or the automatic tuning component of the database enginemay adjust the granularity of locking accurately.

4 LOCKS ON KEY PREFIXES

Embodiments of locking on key prefixes exploit the key structure of aB-tree to provide key range locking. Consider, for example, a B-treeindex for a multi-column “compound key” with columns (a,b,c,d) and withspecific values (a₀, b₀, c₀, d₀). Any leading prefix such as (a₀, b₀)could be employed as a resource that locks all index entries with keysstarting with these specific key values. In general, a key prefixincludes a subset of the key value starting at the beginning of the keyvalue (that is, reading the key value left to right). Examples discussedbelow use a column as a prefix of a compound key. However, one skilledin the art will appreciate that a key based on a single column may alsohave a key prefix. For example, the letters “Jo” are a key prefix forkey values “Johnson” and “Jones.”

It will be appreciated that locks on key prefixes may match with querypredicates. For example a query clause “where a=a₀ and b=b₀” would matchthe lock on (a₀, b₀) discussed above. More complex predicates map toonly a few very precise locks. For example, a query with the clause“where a in (a₀, a₁, a₂) and b in (b₀, b₁, b₂, b₃)” requires only 12locks, independent of the size of the table and the index.

Locking key prefixes may be competitive with predicate locking andprecision locking but without any need for predicate evaluation andconcurrency control.

Locks on key prefixes provide efficient locking for single-row updates,because it is possible to lock a single B-tree entry (recall that allB-tree entries are unique in order to permit accurate deletion).

A lock on a specific value covers all B-tree keys starting with thesevalues. In the example above, a lock on the two-column prefix (a₀, b₀)locks all B-tree keys starting with (a₀, b₀). In order to preventphantom records in serializable transaction isolation, however,non-existent key values also need locking. In short, a phantom recordmay occur when a record is inserted in or deleted from a key range thatis locked. A phantom record appears or disappears from a range after therange is accessed, and thus, creates non-repeatable transactions.

In order to solve the problem of phantom records, locks can be definedto cover only a specific prefix, the gap between two actual prefixvalues, or both. In one embodiment, these locks may include traditionallock modes, such as shown in FIG. 4; in another embodiment, these locksmay include new locks modes as shown in FIG. 5.

In one embodiment, existence of specific key values in the currentB-tree can be decided only after a B-tree search has proceeded to theappropriate index leaf page. Thus, key locking starts only after thenavigation from the B-tree root to the leaf. This navigation isprotected by latches, not locks, including the inspection of the currentleaf contents.

4.1 Insertion and Deletion of Key Values

During insertion of a key in the B-tree, if a key prefix needs to belocked, the lock mode depends on the existence of a prior B-tree entrywith the same prefix value as the new record. If such a prior B-treeentry exists, a key value lock suffices. If no such entry exists, arange lock on the prior key is needed. Note that this range lock onlyneeds to cover the open interval between two pre-existing actual prefixvalues; there is no need to lock either of the key values at the ends ofthe gap. A “gap only” lock, such as discussed in connection with FIG. 5,may be used.

For example, in FIG. 12, a B-tree 1202 is indexed on a key having twocolumns: last name and first name. As shown at 1204, existing records gofrom “Johnson, Mike” to “Smith, Sarah” with no records in between. Toinsert “Johnson, Sally”, a prefix key lock is placed on the prefix“Johnson” so no transactions on records with prefix “Johnson” may bemade while “Johnson, Sally” is inserted.

At 1206, to insert “Miller, Steve”, the gap between “Johnson, Mike” and“Smith, Sarah” is locked. The system locks the absence of the prefix“Miller” so another transaction does not insert a record having theprefix “Miller” (or other last name between “Johnson” and “Smith”)during the current insertion transaction. In one embodiment, new lockmode “ØX” on prefix “Johnson” may be used to lock the gap betweenprefixes “Johnson” and “Smith.”

The initial insertion can be a system transaction that does nothing butinsert a ghost record, leaving it to the user transaction to turn thatghost record into a valid record. While the system transaction requiresa range lock, the user transaction needs to lock only the new key value,not the gap between keys. For example, for the insertion shown at 1206,the gap may be locked using a system transaction for inserting a ghostrecord for “Miller, Steve”, and a follow-on user transaction locks only“Miller, Steve” to flip the ghost record to a valid record. Thus, if alocked key prefix matches the definition of complex objects clustered inthe B-tree by shared key prefixes, a new complex object can be insertedwithout ever locking its neighboring objects or any of their components.

Deletion may follow a similar pattern. A user transaction might simplymark a B-tree entry as a ghost, leaving it to a system transaction toerase the record and its key from the B-tree, or a user transactionmight directly erase the record and the key. Erasing a record requires alock on the record's key in the most restrictive mode, thus ensuringthat no other transaction holds any kind of lock on it. Moreover, thegap between neighboring keys must remain locked in order to ensuresuccessful transaction rollback if required. Gaps must be locked at alllevels in the lock hierarchy for which a distinct value disappears.

4.2 Lock Escalation and De-Escalation

Embodiments of locks on key prefixes may include lock escalation andde-escalation functionality. Two aspects of escalation and de-escalationfor key prefix locking are noted. First, the granularity of locking andthe currently active components of the lock hierarchy are uniform acrossthe entire index. Second, structural modifications to the B-tree, suchas splitting, do not affect the set of locks required. Theseobservations are based on the complete separation of the physical B-treestructure and the locking hierarchy.

For lock escalation, an intention lock is upgraded to an absolute lockfor the appropriate key prefix, and the prior absolute locks can beforgotten or retained for possible subsequent lock de-escalation.

In the embodiment of FIG. 13, B-tree 1202 is indexed on compound key(last name and first name). At 1304, a shared absolute lock is placed oneach of “Johnson, Aaron”, “Johnson, Andrew”, and “Johnson, Brian.” Ashared intention lock is placed the prefix “Johnson.” After lockescalation, as shown at 1306, the shared intention lock on prefix“Johnson” is escalated to a shared absolute lock. This makes the sharedabsolute locks on “Johnson, Aaron”, “Johnson, Andrew”, and “Johnson,Brian” unnecessary.

For lock de-escalation, appropriate information must have been retainedduring the transaction's prior activities such that appropriate locks onlonger prefixes can be inserted into the lock manager's hash table, andthe absolute lock on the short prefix can be downgraded to an intentionlock.

4.3 Granularity Changes

When locking key prefixes, the granularity of locking must be modifieduniformly for the entire index. Changes of granularity in locking keyprefixes affect the entire B-tree. This is contrasted with lockingseparator keys in interior B-tree nodes where modifying the granularityof locking affects each node individually. For example, to add a levelof granularity, a lock on the two-column prefix (a₀, b₀) may be added toa lock hierarchy that has a lock on the three-column prefix (a₀, b₀,c₀). Thus, the set of key prefixes that are locked has been changed(increased in this example). Embodiments of granularity changes in keyprefix locking include an immediate method and a delayed method. Asdiscussed above with separator keys, granularity changes of key prefixlocks may occur dynamically.

Referring to FIG. 14, a B-tree 1402 is indexed using compound key (lastname, first name, middle initial). An absolute lock has been placed onkey prefix “Johnson, Aaron”, as shown at 1404. A granularity changeproceeds as follows. At 1406, a new IS lock is added to all “Johnson”prefixes, shown at 1406. The IS lock is then escalated to an S lock onall “Johnson” prefixes and the S lock on key prefix “Johnson, Aaron” maybe removed, as shown at 1408. When a granularity change is made so thatthe absolute lock is changed to all “Johnson” prefixes, then the numberof records locked increases.

In the delayed method, a system transaction locks all distinct keyvalues at the new granularity of locking across an entire index. Incontrast, hierarchical locking based on separator keys can modify thegranularity of locking one B-tree node at a time.

The immediate method analyzes existing locks in order to acquire onlythose locks that are truly needed for specific active transactions.Hierarchical locking using key prefixes may be more precise thanalternative locking methods and thus there are fewer locks to manage.Note that there might be transactions that do not need any new locks,namely those transactions that own absolute locks at a granularity oflocking larger than the granularity being added. This aspect also holdstrue for separator key locks.

When removing an existing granularity of locking, it is necessary towait for the release of absolute locks at that level. In one embodiment,the database engine waits for an IX lock competing with each suchabsolute lock held by a user transaction.

Embodiments herein may perform hierarchical locking using key prefixes.Key prefix locking reflects the matching between query predicates andkey prefixes. A single mechanism permits locking large ranges orindividual B-tree records, and thus supports equally well decisionsupport, transaction processing, and other applications with similaraccess patterns.

Key prefix locking matches with equality predicates and “in” predicates,which are common both in single-table selections and in joins. Thus,often a single key prefix lock may cover precisely the index entriesneeded, neither more nor less, and consistency and serializability amongsuch a set of index entries are guaranteed, even in transactionisolation levels lower than strict serializability. This aspect iseffective for using key prefix locking for non-unique indexes includingindexes on foreign key columns. This advantage pertains not only tosearches on the full index key but for any prefix of the key. If theleading key column is not specified and multiple index probes arerequired, a single lock per probe may suffice.

If master-detail clustering is supported based on equality of searchcolumns in a B-tree, locking key prefixes provides support for lockingcomplex objects. For example, if orders and order details are co-locatedwithin a B-tree index based on equal values in the common column oforder numbers, locking an order number locks an entire order object andall of its component records. A single lock can also cover a largeobject (for example, a customer with multiple orders, shipments,invoices, and payments). Insertion and deletion of one complex objectdoes not require any lock on its neighbors.

Locking prefixes may also be used with partitioned B-trees. Apartitioned B-tree includes an ordinary B-tree with an artificialleading key column that indicates partitions or, during sorting andindex creation, run numbers. The first granularity of locking is thepartition identifier, which permits efficient operations on partitionssuch as merging partitions, creating an entire partition during dataimport, and dropping a partition while purging old data from a datawarehouse.

5 CONCLUSION

Embodiments herein provide schemes for hierarchical locking. In oneembodiment, new lock modes are presented that enable locking of keys andgaps between keys. These new lock modes not only permit additionalconcurrency compared to earlier designs but also avoid unconventionallocks modes that violate traditional two-phase locking.

Embodiments herein include key range locking using separator keys foundwithin a B-tree structure. Key range locking in parent and grandparentnodes scales with additional B-tree levels and adapts to skewed orunpredictable key distributions. The ability to lock a B-tree in levelsbetween a root node and individual keys eliminates the dilemma betweenthe massive overhead due to many individual locks on keys and massiveconcurrency contention due to a single B-tree index lock to lock thewhole B-tree. Moreover, splitting pages at keys that minimize the sizeof truncated separator keys matches the key ranges in parent andgrandparent nodes to clusters of records and complex objects. Systemtransactions may be used for insertion and deletion of records inseparator key locking.

Embodiments herein include key prefix locking of key ranges. Lockingprefix values of search keys matches query predicates and complexobjects in merged indexes. Insertions and deletions of records withinthe locked key range may be performed using system transactions.

Embodiments herein include dynamic granularity changes in separator keylocking and in key prefix locking. Dynamic changes may be made in thelock hierarchy in response to skew in the data or in the accesspatterns. These dynamic changes are online and incremental such thatthey minimize disruption to ongoing transaction processing and they maybe invoked on demand. Granularity changes may be performed using animmediate method or a delayed method.

Various operations of embodiments of the present invention are describedherein. In one embodiment, one or more of the operations described mayconstitute computer readable instructions stored on computer readablemedia, which if executed by a computing device, will cause the computingdevice to perform the operations described. The order in which some orall of the operations are described should not be construed as to implythat these operations are necessarily order dependent. Alternativeordering will be appreciated by one skilled in the art having thebenefit of this description. Further, it will be understood that not alloperations are necessarily present in each embodiment of the invention.

The above description of embodiments of the invention, including what isdescribed in the Abstract, is not intended to be exhaustive or to limitthe embodiments to the precise forms disclosed. While specificembodiments and examples of the invention are described herein forillustrative purposes, various equivalent modifications are possible, asthose skilled in the relevant art will recognize in light of the abovedetailed description. The terms used in the following claims should notbe construed to limit the invention to the specific embodimentsdisclosed in the specification. Rather, the following claims are to beconstrued in accordance with established doctrines of claiminterpretation.

1. A method, comprising: placing a lock on a separator key of an indexnode of a B-tree index, wherein the lock locks a key range from theseparator key to a next separator key; and at least one additional setof features selected from the group consisting of: (a) splitting a childnode of the index node, wherein splitting the child node includesinserting a new separator key in the index node; duplicating the lock onthe separator key; and applying the lock to the new separator key; (b)escalating the lock on the separator key including: upgrading the lockfrom a first intention lock to a first absolute lock; and eliminatinglocks on keys in the child nodes of the index node; (c) de-escalatingthe lock on the separator key including downgrading the lock from asecond absolute lock to a second intention lock and placing locks onkeys in child nodes of the index node; and (d) locking separator keys inonly a subset of index nodes within the B-tree index, wherein the indexnode is in the subset of index nodes; and changing the set of indexnodes in which separator keys are locked.
 2. The method of claim 1, theadditional set of features comprising: splitting the child node of theindex node, wherein splitting the child node includes inserting the newseparator key in the index node; duplicating the lock on the separatorkey; and applying the lock to the new separator key.
 3. The method ofclaim 1, the additional set of features comprising: escalating the lockon the separator key including: upgrading the lock from the firstintention lock to the first absolute lock; and eliminating locks on keysin the child nodes of the index node.
 4. The method of claim 1, theadditional set of features comprising: de-escalating the lock on theseparator key including downgrading the lock from the second absolutelock to the second intention lock and placing locks on keys in childnodes of the index node.
 5. The method of claim 1, the additional set offeatures comprising: locking separator keys in only the subset of indexnodes within the B-tree index, wherein the index node is in the subsetof index nodes; and changing the set of index nodes in which separatorkeys are locked.
 6. One or more computer readable storage mediaincluding computer readable instructions that, when executed by acomputing device, perform the method of claim
 1. 7. A method,comprising: placing a lock on a key prefix of a B-tree index, whereinthe lock locks each key in a key range having the key prefix; and atleast one additional set of features selected from the group consistingof: (a) deleting a key having the key prefix from the key range, whereindeleting the key includes: marking the key as a ghost record by a usertransaction, the user transaction not requiring locking of the key'sneighboring objects, the user transaction not requiring locking of anyof the components of the key's neighboring objects; and eliminating theghost record by a system transaction; (b) escalating the lock on the keyprefix including upgrading the lock from a first intention lock to afirst absolute lock; (c) de-escalating the lock on the key prefixincluding downgrading the lock from a second absolute lock to a secondintention lock; (d) locking a subset of key prefixes for the B-treeindex, wherein the key prefix is in the subset of key prefixes; andchanging the subset of key prefixes to lock.
 8. The method of claim 7,the additional set of features comprising: deleting the key having thekey prefix from the key range, wherein deleting the key includes:marking the key as the ghost record by the user transaction, the usertransaction not requiring locking of the key's neighboring objects, theuser transaction not requiring locking of any of the components of thekey's neighboring objects; and eliminating the ghost record by thesystem transaction.
 9. The method of claim 7, the additional set offeatures comprising: escalating the lock on the key prefix includingupgrading the lock from the first intention lock to the first absolutelock.
 10. The method of claim 7, the additional set of featurescomprising: de-escalating the lock on the key prefix includingdowngrading the lock from the second absolute lock to the secondintention lock.
 11. The method of claim 7, the additional set offeatures comprising: locking the subset of key prefixes for the B-treeindex, wherein the key prefix is in the subset of key prefixes; andchanging the subset of key prefixes to lock.
 12. One or more computerreadable storage media including computer readable instructions that,when executed by a computing device, perform the method of claim
 7. 13.The method of claim 11, the changing the subset of key prefixes to lockcomprising a delayed granularity change.
 14. The method of claim 11, thechanging the subset of key prefixes to lock comprising an immediategranularity change.